﻿using HAF.LogUtility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TarManager
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string zipFile = textBox1.Text;
                string fileName = Path.GetFileNameWithoutExtension(zipFile);
                string unPackPath = Path.Combine("D:\\FTP\\", fileName);
                Stopwatch _stopwathc = new Stopwatch();
                _stopwathc.Start();
                //压缩包文件的解压操作
                SharpZipper.UnpackTarFile(zipFile, unPackPath);
                _stopwathc.Stop();
                LogHelper.WriteDebugLog("解压时长为{0}", FileAssistant.GetTimeStr(_stopwathc.ElapsedMilliseconds));
            }
            catch (Exception ex)
            {
                LogHelper.WriteErrorLog(ex.ToString());
            }
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string zipFile = textBox2.Text;
                string fileName = Path.GetFileNameWithoutExtension(zipFile);
                string unPackPath = Path.GetDirectoryName(zipFile); //Path.Combine("D:\\FTP\\", fileName);
                Stopwatch _stopwathc = new Stopwatch();
                _stopwathc.Start();
                //压缩包文件的解压操作
                SharpZipper.UnpackZipFile(zipFile, unPackPath);
                _stopwathc.Stop();
                LogHelper.WriteDebugLog("解压时长为{0}", FileAssistant.GetTimeStr(_stopwathc.ElapsedMilliseconds));
            }
            catch (Exception ex)
            {
                LogHelper.WriteErrorLog(ex.ToString());
            }
        }
    }
}
